//#include <stdio.h>
//#include <Windows.h>
//#include <string>
//#include <iostream>
//#include <process.h>
//
//#include "../tAutomaLibCpp/tAutomaLibCpp.hpp"
//#include <string>
//#include <Windows.h>
//
//#include <iostream>
//
//using namespace std;
//
///* Define functions prototype */
//#pragma region MyRegion
//typedef unsigned char(*dll_detect)(unsigned short ports[10]);
//typedef unsigned char(*dlltz_detect)(unsigned short ports[10]);
//
//typedef unsigned long long(*dll_initialize)(unsigned short nPort);
//typedef unsigned long long(*dlltz_initialize)(unsigned short nPort);
//typedef unsigned char(*dll_close)(unsigned long long handle);
//#pragma endregion
//
//
////===============================================================
////		Main function
////===============================================================
//int main()
//{
//	std::cout << "This is a example of calling pgmfc dll." << std::endl;
//
//	HMODULE hDll = NULL;
//	hDll = LoadLibrary(L"pgmfc_64.dll");
//
//	if (!hDll)
//	{
//		std::cout << "PGMFC dll load failed" << std::endl;
//		return -1;
//	}
//
//	/* Declare pointers on dll functions */
//#pragma region pointers
//	dll_detect detect = (dll_detect)GetProcAddress(hDll, "mfcs_detect");
//	dlltz_detect tz_detetct = (dlltz_detect)GetProcAddress(hDll, "mfcstz_detect");
//
//	dll_initialize initialize = (dll_initialize)GetProcAddress(hDll, "mfcs_initialization");
//	dlltz_initialize tz_initialize = (dlltz_initialize)GetProcAddress(hDll, "mfcstz_initialization");
//
//	dll_close close = (dll_close)GetProcAddress(hDll, "mfcs_close");
//
//#pragma endregion
//
//	/* check connected flowcontrollers */
//	///*
//	cout << "\n>>>>>>>> Detecting flowcontrollers.....\n" << endl;
//	unsigned short validControllers[10] = { 0 };
//	unsigned char validPort = detect(validControllers);
//
//	//int port = 3;
//	int port = 2; // by JM
//	for (unsigned char i = 0; i < validPort; i++)
//	{
//		cout << "Find Controller" << " COM" << validControllers[i] << endl;
//	}
//	if (validPort == 0)
//	{
//		cout << "No MFCS Series device detected" << endl;
//	}
//	else {
//		port = validControllers[0];
//	}
//	//*/
//	unsigned short validControllers_sz[10] = { 0 };
//
//	/* Initialize device */
//	/* Initialize the first MFCS in Windows enumeration list */
//	cout << "\n>>>>>>>> initialize...\n" << endl;
//	unsigned long long handle = 0;  // Local instrument handle
//	if (port >= 0 && port < 100)
//		handle = initialize(port);
//	else
//	{
//		printf("\nno Invalid mfcs or mfcstz controller");
//	}
//
//	if (handle == NULL)
//	{
//		printf("\nInvalid controller");
//	}
//	else {
//		unsigned char version[20] = { 0 };
//		Sleep(5);
//
//		/* Close MFCS session */
//		close(handle);
//		std::cout << "\nPGMFCS closed" << std::endl;
//
//		/* Release the DLL */
//		FreeLibrary(hDll);
//		std::cout << "\nPGMFCS dll unloaded" << std::endl;
//	}
//
//
//	/* Exit application */
//	system("PAUSE");
//
//
//	return 0;
//}